{{- /*
@param {string} (positional parameter 0) Spoiler title.
@param {string} (positional parameter 1) Spoiler type.

@returns {template.HTML}

@examples

  {{< spb "Spoiler" "danger" >}}
  Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus vehicula vel neque id vestibulum.
  Nulla cursus, nisl sed fermentum iaculis, urna arcu mollis mi, non fringilla turpis nisl vitae eros.
  {{< /spb >}}
*/ -}}

{{ $title := ((.Get 0) | default (printf "Spoiler #%d" (.Ordinal))) }}
{{ $type := ((.Get 1) | default "primary") }}
{{ $types := (slice "primary" "secondary" "success" "danger" "warning" "info" "light" "dark") }}

{{ with ($type) }}
    {{ if (not (in ($types) .)) }}
        {{ (errorf "The type passed to the %q shortcode is invalid. The type must be one of %s. See %s." ($.Name) (delimit ($types) ", " ", or ") ($.Position)) }}
    {{ end }}
{{ end }}

{{ $id := ((printf "sc-%s-%s" ($.Name) (delimit (shuffle (seq 11 99)) "")) | md5) }}

<div class="shortcode shortcode-{{ ($.Name) }}">
  <p>
    <a class="btn btn-{{ ($type) }}" href="#" role="button" tabindex="0"
       data-bs-toggle="collapse" data-bs-target="#sc-{{ ($id) }}"
       aria-label="{{ ($title) }}">
      <span>{{ ($title) }}</span>
    </a>
  </p>
  <div class="collapse" id="sc-{{ ($id) }}">
    <div class="card card-body mb-3">
        {{ with (.Inner) }}{{ (. | $.Page.RenderString (dict "display" "block")) }}{{ end }}
    </div>
  </div>
</div>
